package com.wit.witmg.api;


import com.wit.witmg.service.ITMonitDustService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author bob
 * @since 2025-08-11
 */
@RestController
@RequestMapping("monitdust")
@Api(tags = "粉尘数据API")
public class MonitDustController {
    @Resource
    private ITMonitDustService service;
    @ApiOperation("修改")
    @PostMapping("add")
    public Object add(HttpServletRequest request,
                      @RequestParam("json") String json) {
        return service.add(request,json);
    }

    @ApiOperation("查询")
    @PostMapping("get")
    public Object get(HttpServletRequest request,
                      @RequestParam(value = "dt0",required = false) Long dt0,
                      @RequestParam(value = "dt1",required = false) Long dt1,
                      @RequestParam(value = "sid",required = false) String sid,
                      @RequestParam(value = "loca",required = false) String loca) {
        return service.get(request,dt0,dt1,sid,loca);
    }

    @ApiOperation("发送命令到设备")
    @PostMapping("command")
    public Object command(
            @RequestParam("sbid") Integer sbid,
            @RequestParam(value = "command",required = false) String command ) {
        return service.sendCommandToDevice(sbid,command);
    }
}
